package dao

import (
	"context"
	"fmt"
	"onerk4/zk1/global"
	"time"
)

func SetSms(mobile, source string, code int) error {
	key := fmt.Sprintf("sms:%s:%s", source, mobile)
	err := global.Rdb.Set(context.Background(), key, code, time.Minute*5).Err()
	if err != nil {
		return err
	}
	return nil
}

func GetSms(mobile, source string) (string, error) {
	key := fmt.Sprintf("sms:%s:%s", source, mobile)
	result, err := global.Rdb.Get(context.Background(), key).Result()
	if err != nil {
		return "", err
	}
	return result, nil
}
